package com.example.service.Service;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MusiceService2 extends Service {
    private MusicHelper musicHelper = null;

    public MusiceService2() {
    }

    @Override
    public void onCreate(){
        Log.d("MusicService2......", "onCreate");
        super.onCreate();
        musicHelper = new MusicHelper(this);
    }

    @Override
    public void onDestroy(){
        Log.d("MusicService2......", "onDestroy");
        super.onDestroy();
        musicHelper.destroy();
        musicHelper = null;
    }

    public class MyBinder extends Binder {
        private MusiceService2 service;
        public MyBinder(MusiceService2 service){
            this.service = service;
        }

        public void play(){
            service.musicHelper.play();
        }

        public void next(){
            service.musicHelper.next();
        }

        public void pause(){
            service.musicHelper.pause();
        }

        public void destroy(){
            service.musicHelper.destroy();
        }
    }

    @Override
    public IBinder onBind(Intent intent) {
        Log.d("MusicService2------", "onBind");
        return new MyBinder(this);
    }
}